package A_review.review1_17;

import org.omg.CORBA.INTERNAL;

public class Class53 {
    public int maxSubArray(int[] nums) {
        int len = nums.length;
        int[] dp=new int[len];
        dp[0]=nums[0];
        int max= Integer.MIN_VALUE;
        for (int i = 1; i <len; i++) {
            dp[i]=Math.max(dp[i-1]+nums[i],nums[i]);
            max=Math.max(max,dp[i]);
        }
          return  max>dp[0]?max:dp[0];
    }

    public static void main(String[] args) {
        Class53 class53 = new Class53();
        int[] cur={5,4,-1,7,8};
        System.out.println(class53.maxSubArray(cur));
    }




}
